package cz.jm.web.manhunter.shared;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import cz.jm.web.manhunter.server.authentication.Account;

@SuppressWarnings("serial")
public class User implements Serializable {
	public enum UserState {
		UNKNOWN, REGISTERED_UNVERIFIED, OK, ERROR, USERNAME_ALREADY_EXISTS, MAIL_ALREADY_EXISTS, USERNAME_AND_MAIL_ALREADY_EXISTS, AUTHENTICATION_FAILED
	}

	public static final long INVALID_ID = Account.INVALID_ID;
	private long id = INVALID_ID;
	private String username;
	private String mail;
	private List<String> phoneNumbers = new ArrayList<String>();
	private UserState state = UserState.UNKNOWN;
	
	public User() {
	}

//	public User(Account account) {
//		initFromAccount(account);
//	}

	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getMail() {
		return mail;
	}

	public void setMail(String mail) {
		this.mail = mail;
	}

	public List<String> getPhoneNumbers() {
		return phoneNumbers;
	}

	public void setPhoneNumbers(List<String> phoneNumbers) {
		this.phoneNumbers = phoneNumbers;
	}

	public static long getInvalidId() {
		return INVALID_ID;
	}

	public boolean isValid() {
		return getId() != INVALID_ID;
	}

//	public void initFromAccount(Account account) {
//		id = account.getId();
//		username = account.getUsername();
//		mail = account.getMail();
//		// Account ma tel. cisla vlozene v specialnej lazy implamentacii
//		// List-u, ktora nejde serializovat a preto treba vytvorit novy zoznam.
//		phoneNumbers = new ArrayList<String>(account.getPhoneNumbers());
//		setState(UserState.OK);
//	}

	public UserState getState() {
	    return state;
    }

	public void setState(UserState state) {
	    this.state = state;
    }

}
